#!/bin/bash
#目前还没达到预期的效果
#定义函数及相应的功能
    function delConSpaLine() {
        sed '/./,/^$/!d' $1
        cat $1
    }

    function delFirstSpaLine() {
        sed '/./,$!d' $1
        cat $1
    }

    function delEndSpaLine() {
        sed '{:start /^\n*$/{$d ; N ; b start }}' $1
        cat $1
    }

    function menu() {
        echo
        echo -e "\t1.Delete Continous Space Line"
        echo -e "\t2.Delete First Space Line"
        echo -e "\t3.Delete End Space Line"
        echo -e "\t4.Exit"
        echo -en "\t\tEnter your option: "
        read -n 1 option
    }
#循环执行
    while [ 1 ]
    do
        menu
        case $option in
            1)
                delConSpaLine ;;
            2)
                delFirstSpaLine ;;
            3)
                delEndSpaLine ;;
            4)
                break ;;
            *)
                echo "Oops~"
        esac
        echo -en "Hit any key to continue..."
        read -n 1 line
    done
    clear
